<!-- 需要传入参数的分页组件 -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>

<% //请求方式                    服务器名，地址                          端口
    String path = request.getContextPath();      //上下文路径，/mldn
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!-- 参数如下 -->
<%
    int currentPage = (Integer) request.getAttribute("cp");
    int countAll = (Integer) request.getAttribute("allRecorders");
    int seed = 2;
//    int ls = (Integer) request.getAttribute("ls");
    int ls = 7;
    String kw = (String) request.getParameter("kw");
    String col = "";
    if (request.getParameter("col") != null) {
        col = request.getParameter("col");
    }
    String url = (String) request.getAttribute("url");
%>
<ul class="pagination pagenav">
    <li><a href="<%=basePath%><%=url%>?cp=1&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"
           aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
    </a></li>
    <%
        if (currentPage < 3) {
            for (int i = 1; i <= 5; i++) {
                if (i < countAll) {
                    if (i == currentPage) {
    %>
    <li class="active"><a
            href="<%=basePath%><%=url%>?cp=<%=i%>&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"><%=i%>
    </a></li>
    <%
    } else {
    %>
    <li><a href="<%=basePath%><%=url%>?cp=<%=i%>&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"><%=i%>
    </a></li>
    <%
                }
            }
        }
    } else {
        for (int i = currentPage - seed; i <= currentPage + seed; i++) {
            if (i == currentPage) {
    %>
    <li class="active"><a
            href="<%=basePath%><%=url%>?cp=<%=i%>&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"><%=i%>
    </a></li>
    <%
    } else {
    %>
    <li><a href="<%=basePath%><%=url%>?cp=<%=i%>&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"><%=i%>
    </a></li>
    <%
                }
            }
        }
    %>
    <li><a
            href="<%=basePath%><%=url%>?cp=<%=(countAll / ls)+1%>&ls=<%=ls%>&kw=<%=kw%>&col=<%=col%>"
            aria-label="Next"> <span aria-hidden="true">&raquo;</span>
    </a></li>
</ul>